<!--From表单-默认输入框-->
<div th:fragment="pa-form-input(type,showNamme,name,md,maxlength,verify,value)" th:class="|layui-inline ${md} p-tr-sm|">
    <label class="layui-form-label" th:text="${showNamme}" th:title="${showNamme}"></label>
    <div class="layui-input-block">
        <input class="layui-input" autocomplete="off" th:type="${type}" th:lay-name="${showNamme}" th:name="${name}" th:maxlength="${maxlength}" th:lay-verify="${verify}" th:value="${value}">
    </div>
</div>
<div th:fragment="pa-form-textarea(type,showNamme,name,md,row,verify,value)" th:class="|layui-form-item layui-form-text ${md} p-tr-sm|">
    <label class="layui-form-label" th:text="${showNamme}" th:title="${showNamme}"></label>
    <div class="layui-input-block">
        <textarea th:name="${name}" th:lay-name="${showNamme}" th:lay-verify="${verify}" class="layui-textarea" th:rows="${row}" th:text="${value}"></textarea>
    </div>
</div>
<div th:fragment="pa-form-input-detail(type,showNamme,md,value)" th:class="|layui-inline ${md} p-tr-sm|">
    <label class="layui-form-label" th:text="${showNamme}" th:title="${showNamme}"></label>
    <div class="layui-input-block">
        <input disabled readonly class="layui-input layui-bg-gray" autocomplete="off" th:type="${type}" th:value="${value}">
    </div>
</div>
<div th:fragment="pa-form-textarea-detail(showNamme,md,row,value)" th:class="|layui-form-item layui-form-text ${md} p-tr-sm|">
    <label class="layui-form-label" th:text="${showNamme}" th:title="${showNamme}"></label>
    <div class="layui-input-block">
        <textarea class="layui-textarea layui-bg-gray" th:rows="${row}" th:text="${value}" disabled readonly></textarea>
    </div>
</div>

<!--From表单-默认下拉框-->
<div th:fragment="pa-form-select(option,showNamme,name,md,verify,value,defalutDesc)" th:class="|layui-inline ${md} p-tr-sm|">
    <label class="layui-form-label" th:text="${showNamme}" th:title="${showNamme}"></label>
    <div class="layui-input-block">
        <select th:lay-name="${showNamme}" th:name="${name}" th:lay-verify="${verify}">
            <option th:if="${defalutDesc} != ''" value="" th:text="${defalutDesc}"></option>
            <option th:each="item:${@lj.codeMap(option)}" th:value="${item.code}" th:text="${item.value}" th:selected="${value}==${item.code}"></option>
        </select>
    </div>
</div>

<!--From表单-默认条件-->
<div th:fragment="pa-input-cond(name,showNamme,md,value)" th:class="|layui-inline ${md} p-r-xxs|">
    <label class="layui-form-label" th:text="${showNamme}" th:title="${showNamme}"></label>
    <div class="layui-input-block"><input class="layui-input" autocomplete="off" type="text" th:name="${name}" th:value="${value}"></div>
</div>
<div th:fragment="pa-select-cond(option,showNamme,name,md,value,defalutDesc)" th:class="|layui-inline ${md} p-r-xxs|">
    <label class="layui-form-label" th:text="${showNamme}" th:title="${showNamme}"></label>
    <div class="layui-input-block">
        <select th:lay-name="${showNamme}" th:name="${name}">
            <option th:if="${defalutDesc} != ''" value="" th:text="${defalutDesc}"></option>
            <option th:each="item:${@lj.codeMap(option)}" th:value="${item.code}" th:text="${item.value}" th:selected="${value}==${item.code}"></option>
        </select>
    </div>
</div>

<!--From表单-远程搜索-->
<div th:fragment="pa-input-xmSelect(id,showNamme,name,md,value,url)" th:class="|layui-inline ${md} p-tr-sm|">
    <label class="layui-form-label" th:text="${showNamme}" th:title="${showNamme}"></label>
    <div th:id="${id}" class="layui-input-block">
        <input type="hidden" th:name="${name}" th:value="${value}">
        <script>
            layui.use(['form', "jquery", 'okAxios'], function () {
                let form = layui.form;
                let $ = layui.jquery;
                let okAxios = layui.okAxios;
                form.render();
                xmSelect.render({
                    el: '#[[${id}]]',
                    radio: true,
                    autoRow: true,
                    direction: 'up',
                    toolbar: {show: false},
                    filterable: true,
                    remoteSearch: true,
                    model: {label: {type: 'text'}},
                    remoteMethod: function (val, cb, show) {
                        if (!val) {return cb([]);}
                        okAxios.get('[[${url}]]', {
                            params: {keyword: val}
                        }).then(response => {
                            //{value: "16502561362470", name: "北京市__12", selected: false, disabled: false}
                            let res = response.data;
                            cb(res.data)
                        }).catch(err => {
                            cb([]);
                        });
                    }, on: function (data) {
                        let arr = data.arr;
                        let name = ".layui-input[name='[[${name}]]']";
                        if (arr.length >= 1) {
                            $(name).val(arr[0].value);
                        } else {
                            $(name).val("");
                        }
                    }
                })
            })
        </script>
    </div>
</div>

<!--From表单-日期选中框-->
<script th:fragment="pa-input-datatime(array)">
    layui.use(["jquery", "laydate"], function () {
        let laydate = layui.laydate;
        let $ = layui.jquery;
        let array = '[[${array}]]';
        $.each(array.split(","), function (i, n) {
            laydate.render({
                elem: ".layui-input[name=" + n + "]",
                type: "datetime",
                ready: function () {
                    // 双击直接默认确认日期
                    $(".layui-laydate-content td").dblclick(function () {
                        $(".laydate-btns-confirm").click();
                    });
                }
            });
        });
    })
</script>